package csci3033.RecordaNote;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MarkerAdapter extends ArrayAdapter<Marker>{

	private ArrayList<Marker> markers;
	
	public MarkerAdapter(Context context, int textViewResourceId,
			ArrayList<Marker> objects) {
		super(context, textViewResourceId, objects);
		this.markers = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
        if (view == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = vi.inflate(R.layout.marker_row, null);
        }
        Marker currentMarker = markers.get(position);
        if (currentMarker != null) {
        	//currentMarker.setName("Marker ");
        	//currentMarker.setNotes("TIME");
        	TextView txtName  = (TextView) view.findViewById(R.id.txtName);
        	TextView txtMarkerTime = (TextView) view.findViewById(R.id.txtMarkerTime);
        	txtName.setText(currentMarker.getName());
        	txtMarkerTime.setText(currentMarker.getMarkerTimestamp());
        }
        
        return view;
	}
}
